﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ComputerArchitecture.Core;
using ComputerArchitecture.Core.Logging;
using ComputerArchitecture.Numbers;
using ComputerArchitecture.Units.Interfaces;

namespace ComputerArchitecture.Units.Float
{
    public class FloatNegateUnit : LoggingObject, IFloatNegateUnit
    {
        #region Constructors

        public FloatNegateUnit(ILoggingService loggingService) 
            : base(loggingService)
        {
        }

        #endregion

        #region Methods

        public IFloatPointNumber Negate(IFloatPointNumber value)
        {
            ArgumentValidator.NullValidate(value);
            this.LoggingService.LogInfo("Negate value: {0}", value);
            IFloatPointNumber result = (IFloatPointNumber) value.Clone();
            if (result.SignBit.IsSet)
            {
                result.SignBit.Reset();
            }
            else
            {
                result.SignBit.Set();
            }
            this.LoggingService.LogInfo("Result: {0}", result);
            return result;
        }

        #endregion
    }
}
